var RunLayer = cc.Layer.extend({
	arr:null,
	scene:null,
	clock:null,
	ctor:function (parent) {
		this._super();
		this.scene = parent;
		this.scene.addChild(this, 10);
		gg.main = this;
		this.init();
	},
	init:function () {
		this.callNext = cc.callFunc(function(){
			gg.flow.next();
		}, this);
		this.callNext.retain();
		this.clock = new Clock(this);
		// 物品库
		this.lib = new Lib(this);
		this.balance=new Balance(this);
		this.balance.setPosition(gg.width*0.35,gg.height*0.4);
		this.addChild(this.balance, 10);
		this.scheduleOnce(function(){
		},1);
	},
	loadTest:function(){
 this.lib.moveLib(TAG_LIB_SALT,400);
	},
	test2:function(){
		var move = cc.moveTo(0.7,cc.p(570,320));
		var rotate = cc.rotateTo(0.8, 90);
		var func = cc.callFunc(function(){
			ss.pour2();
			ss.hide(3, true);
		},this);
		var seq = cc.sequence(move, rotate, func);
		ss.runAction(seq);
	},
	loadWeighing:function(pos){
		var weighing=new Weighing(this);
		this.addChild(weighing,11);
		this.loadInLib(weighing, pos,cc.p(gg.width*0.55,gg.height*0.35),null,0);
	},
	loadBeaker:function(pos){
		var beaker=new Beaker(this);
		this.addChild(beaker,11);
		this.loadInLib(beaker, pos,cc.p(gg.width*0.55,gg.height*0.3),null,1);
	},
	loadBook:function(pos){
		var book=new Book(this);
		this.addChild(book,11);
		this.loadInLib(book, pos,cc.p(gg.width*0.55,gg.height*0.3),null,1);
	},
	loadBrush:function(pos){
		var brush=new Brush(this);
		this.addChild(brush,11);
		this.loadInLib(brush, pos,cc.p(gg.width*0.65,gg.height*0.4),null,1);
	},
	loadKettle:function(pos){
		var kettle=new Kettle(this);
		this.addChild(kettle,11);
		this.loadInLib(kettle, pos,cc.p(gg.width*0.75, gg.height*0.35),null,1);
	},
	loadGlass:function(pos){
		var action=gg.flow.flow.action;
		if(action==ACTION_DO1){
			var glass=new Glass(this,action);
			this.addChild(glass,11);
			this.loadInLib(glass, pos,cc.p(gg.width*0.68, gg.height*0.35),null,1);
		}else if(action==ACTION_DO2){
			var glass=new Glass(this,action);
			this.addChild(glass,10);
			this.loadInLib(glass, pos,cc.p(gg.width*0.25, gg.height*0.35),null,1);
		}
	},
	loadFlask:function(pos){
		var flask=new Flask(this);
		this.addChild(flask,11);
		this.loadInLib(flask, pos,cc.p(gg.width*0.35, gg.height*0.35),null,1);
	},
	loadDrop:function(pos){
		var drop=new Drop(this);
		this.addChild(drop,9);
		this.loadInLib(drop, pos,cc.p(gg.width*0.65, gg.height*0.3),null,1);
	},
	loadInLib:function(obj, pos, tarPos,delay,s){
		obj.setPosition(pos);
		if(delay == null){
			delay = 1;
		}
		var ber = $.bezier(pos, tarPos, delay);
		if(s==0){
			var seq = cc.sequence(ber);
		}else{
			var seq = cc.sequence(ber, this.callNext);
		}
		obj.runAction(seq);
	},
	kill:function(obj){
		var fade = cc.fadeTo(0.5,0);
		var func = cc.callfunc(function(){
			obj.removeFromParent(true);
		},this);
		var seq = cc.sequence(fade,func);
		obj.runAction(seq)
	}
});